!function() {
    function t(t) {
        return t = t || {}, c = e(c, t), r(), a();
    }
    function e(t, e) {
        for (var r in e) e.hasOwnProperty(r) && (t[r] = e[r]);
        return t;
    }
    function r() {
        l = wx.createCanvasContext(c.id);
    }
    function a() {
        return new Promise(function(t) {
            l.setGlobalAlpha(1), l.scale(1, 1), l.drawImage(c.imgUrl, 0, 0, c.width, c.height), 
            l.setFillStyle(c.color), l.setFontSize(c.size), l.rotate(Math.PI / 180 * c.rotate), 
            l.setGlobalAlpha(c.opacity), 1 > c.scale && l.scale(c.scale, c.scale), n(), l.draw(), 
            t();
        });
    }
    function n() {
        var t = c.xSpace, e = c.ySpace, r = c.text.length, a = c.size + e, n = c.size * r + t, i = .72 * (c.width + c.height);
        1 > c.scale && (i /= c.scale);
        for (var o = c.yStart; o < i + a; o += a) for (var s = c.xStart; s < i + n; s += n) l.fillText(c.text, s, o);
    }
    function i() {
        l.clearRect(0, 0, c.width, c.height);
    }
    function o(t) {
        return i(), t = t || {}, c = e(c, t), a();
    }
    var c = {
        text: "watermark",
        rotate: 15,
        xSpace: 20,
        ySpace: 20,
        size: 20,
        xStart: -50,
        yStart: 20,
        opacity: .2,
        color: "#000",
        width: 500,
        height: 500,
        imgUrl: "",
        id: "",
        parent: null
    }, l = null;
    module.exports = function() {
        return {
            mark: t,
            reRendering: o
        };
    };
}();